import {AfterViewInit, Component, OnInit} from '@angular/core';
import {OauthService} from './lib/service/oauth.service';
import { Router, NavigationEnd } from '@angular/router';
import {NgProgress} from "ngx-progressbar";

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss'],
})


export class AppComponent implements OnInit,AfterViewInit {

  constructor(private oauthService: OauthService,private router:Router, private ngProgress: NgProgress) {
    this.router.events.subscribe(event => {
          this.ngProgress.start();
      if (event instanceof NavigationEnd) {
        this.ngProgress.done();
      }
    });
  }

  ngOnInit() {
    this.oauthService.doRefresh();
    setInterval(() => {
      // 定时刷新token
      this.oauthService.doRefresh();
    }, 10000);
  }

  ngAfterViewInit() {
    console.log(this.router.url);
  }
}
